/*** Copyright (c), The Regents of the University of California            ***
 *** For more information please refer to files in the COPYRIGHT directory ***/

#include "rods.h"

#ifdef IRODS_SYSLOG
#ifndef windows_platform
#include <syslog.h>
#endif
#endif

#include "rodsLog.h"
#include "rcGlobalExtern.h"
#include "rcMisc.h"
#include <time.h>
#include <sys/time.h>

#ifndef windows_platform
#include <unistd.h>
#endif

#ifdef windows_platform
#include "irodsntutil.h"
#endif

#define BIG_STRING_LEN MAX_NAME_LEN+300
#include <stdarg.h>

/* The following code is inserted by the errorSetup.pl script 
   when rodsErrorTable.h is updated. */

/* BEGIN generated code */
   int irodsErrors[]={ 
    SYS_SOCK_OPEN_ERR, 
    SYS_SOCK_BIND_ERR, 
    SYS_SOCK_ACCEPT_ERR, 
    SYS_HEADER_READ_LEN_ERR, 
    SYS_HEADER_WRITE_LEN_ERR, 
    SYS_HEADER_TPYE_LEN_ERR, 
    SYS_CAUGHT_SIGNAL, 
    SYS_GETSTARTUP_PACK_ERR, 
    SYS_EXCEED_CONNECT_CNT, 
    SYS_USER_NOT_ALLOWED_TO_CONN, 
    SYS_READ_MSG_BODY_INPUT_ERR, 
    SYS_UNMATCHED_API_NUM, 
    SYS_NO_API_PRIV, 
    SYS_API_INPUT_ERR, 
    SYS_PACK_INSTRUCT_FORMAT_ERR, 
    SYS_MALLOC_ERR, 
    SYS_GET_HOSTNAME_ERR, 
    SYS_OUT_OF_FILE_DESC, 
    SYS_FILE_DESC_OUT_OF_RANGE, 
    SYS_UNRECOGNIZED_REMOTE_FLAG, 
    SYS_INVALID_SERVER_HOST, 
    SYS_SVR_TO_SVR_CONNECT_FAILED, 
    SYS_BAD_FILE_DESCRIPTOR, 
    SYS_INTERNAL_NULL_INPUT_ERR, 
    SYS_CONFIG_FILE_ERR, 
    SYS_INVALID_ZONE_NAME, 
    SYS_COPY_LEN_ERR, 
    SYS_PORT_COOKIE_ERR, 
    SYS_KEY_VAL_TABLE_ERR, 
    SYS_INVALID_RESC_TYPE, 
    SYS_INVALID_FILE_PATH, 
    SYS_INVALID_RESC_INPUT, 
    SYS_INVALID_PORTAL_OPR, 
    SYS_PARA_OPR_NO_SUPPORT, 
    SYS_INVALID_OPR_TYPE, 
    SYS_NO_PATH_PERMISSION, 
    SYS_NO_ICAT_SERVER_ERR, 
    SYS_AGENT_INIT_ERR, 
    SYS_PROXYUSER_NO_PRIV, 
    SYS_NO_DATA_OBJ_PERMISSION, 
    SYS_DELETE_DISALLOWED, 
    SYS_OPEN_REI_FILE_ERR, 
    SYS_NO_RCAT_SERVER_ERR, 
    SYS_UNMATCH_PACK_INSTRUCTI_NAME, 
    SYS_SVR_TO_CLI_MSI_NO_EXIST, 
    SYS_COPY_ALREADY_IN_RESC, 
    SYS_RECONN_OPR_MISMATCH, 
    SYS_INPUT_PERM_OUT_OF_RANGE, 
    SYS_FORK_ERROR, 
    SYS_PIPE_ERROR, 
    SYS_EXEC_CMD_STATUS_SZ_ERROR, 
    SYS_PATH_IS_NOT_A_FILE, 
    SYS_UNMATCHED_SPEC_COLL_TYPE, 
    SYS_TOO_MANY_QUERY_RESULT, 
    SYS_SPEC_COLL_NOT_IN_CACHE, 
    SYS_SPEC_COLL_OBJ_NOT_EXIST, 
    SYS_REG_OBJ_IN_SPEC_COLL, 
    SYS_DEST_SPEC_COLL_SUB_EXIST, 
    SYS_SRC_DEST_SPEC_COLL_CONFLICT, 
    SYS_UNKNOWN_SPEC_COLL_CLASS, 
    SYS_DUPLICATE_XMSG_TICKET, 
    SYS_UNMATCHED_XMSG_TICKET, 
    SYS_NO_XMSG_FOR_MSG_NUMBER, 
    SYS_COLLINFO_2_FORMAT_ERR, 
    SYS_CACHE_STRUCT_FILE_RESC_ERR, 
    SYS_NOT_SUPPORTED, 
    SYS_TAR_STRUCT_FILE_EXTRACT_ERR, 
    SYS_STRUCT_FILE_DESC_ERR, 
    SYS_TAR_OPEN_ERR, 
    SYS_TAR_EXTRACT_ALL_ERR, 
    SYS_TAR_CLOSE_ERR, 
    SYS_STRUCT_FILE_PATH_ERR, 
    SYS_MOUNT_MOUNTED_COLL_ERR, 
    SYS_COLL_NOT_MOUNTED_ERR, 
    SYS_STRUCT_FILE_BUSY_ERR, 
    SYS_STRUCT_FILE_INMOUNTED_COLL, 
    SYS_COPY_NOT_EXIST_IN_RESC, 
    SYS_RESC_DOES_NOT_EXIST, 
    SYS_COLLECTION_NOT_EMPTY, 
    SYS_OBJ_TYPE_NOT_STRUCT_FILE, 
    SYS_WRONG_RESC_POLICY_FOR_BUN_OPR, 
    SYS_DIR_IN_VAULT_NOT_EMPTY, 
    SYS_OPR_FLAG_NOT_SUPPORT, 
    SYS_TAR_APPEND_ERR, 
    SYS_INVALID_PROTOCOL_TYPE, 
    SYS_UDP_CONNECT_ERR, 
    SYS_UDP_TRANSFER_ERR, 
    SYS_UDP_NO_SUPPORT_ERR, 
    SYS_READ_MSG_BODY_LEN_ERR, 
    CROSS_ZONE_SOCK_CONNECT_ERR, 
    SYS_NO_FREE_RE_THREAD, 
    SYS_BAD_RE_THREAD_INX, 
    SYS_CANT_DIRECTLY_ACC_COMPOUND_RESC, 
    SYS_SRC_DEST_RESC_COMPOUND_TYPE, 
    SYS_CACHE_RESC_NOT_ON_SAME_HOST, 
    SYS_NO_CACHE_RESC_IN_GRP, 
    SYS_UNMATCHED_RESC_IN_RESC_GRP, 
    SYS_CANT_MV_BUNDLE_DATA_TO_TRASH, 
    SYS_CANT_MV_BUNDLE_DATA_BY_COPY, 
    SYS_EXEC_TAR_ERR, 
    SYS_CANT_CHKSUM_COMP_RESC_DATA, 
    SYS_CANT_CHKSUM_BUNDLED_DATA, 
    SYS_RESC_IS_DOWN, 
    SYS_UPDATE_REPL_INFO_ERR, 
    SYS_COLL_LINK_PATH_ERR, 
    SYS_LINK_CNT_EXCEEDED_ERR, 
    SYS_CROSS_ZONE_MV_NOT_SUPPORTED, 
    SYS_RESC_QUOTA_EXCEEDED, 
    SYS_RENAME_STRUCT_COUNT_EXCEEDED, 
    SYS_BULK_REG_COUNT_EXCEEDED, 
    SYS_REQUESTED_BUF_TOO_LARGE, 
    SYS_INVALID_RESC_FOR_BULK_OPR, 
    SYS_SOCK_READ_TIMEDOUT, 
    SYS_SOCK_READ_ERR, 
    SYS_CONNECT_CONTROL_CONFIG_ERR, 
    SYS_MAX_CONNECT_COUNT_EXCEEDED, 
    SYS_STRUCT_ELEMENT_MISMATCH, 
    SYS_PHY_PATH_INUSE, 
    SYS_USER_NO_PERMISSION, 
    SYS_USER_RETRIEVE_ERR, 
    SYS_FS_LOCK_ERR, 
    SYS_LOCK_TYPE_INP_ERR, 
    SYS_LOCK_CMD_INP_ERR, 
    SYS_ZIP_FORMAT_NOT_SUPPORTED, 
    SYS_ADD_TO_ARCH_OPR_NOT_SUPPORTED, 
    CANT_REG_IN_VAULT_FILE, 
    PATH_REG_NOT_ALLOWED, 
    SYS_INVALID_INPUT_PARAM, 
    SYS_GROUP_RETRIEVE_ERR, 
    SYS_MSSO_APPEND_ERR, 
    SYS_MSSO_STRUCT_FILE_EXTRACT_ERR, 
    SYS_MSSO_EXTRACT_ALL_ERR, 
    SYS_MSSO_OPEN_ERR, 
    SYS_MSSO_CLOSE_ERR, 
    USER_AUTH_SCHEME_ERR, 
    USER_AUTH_STRING_EMPTY, 
    USER_RODS_HOST_EMPTY, 
    USER_RODS_HOSTNAME_ERR, 
    USER_SOCK_OPEN_ERR, 
    USER_SOCK_CONNECT_ERR, 
    USER_STRLEN_TOOLONG, 
    USER_API_INPUT_ERR, 
    USER_PACKSTRUCT_INPUT_ERR, 
    USER_NO_SUPPORT_ERR, 
    USER_FILE_DOES_NOT_EXIST, 
    USER_FILE_TOO_LARGE, 
    OVERWRITE_WITHOUT_FORCE_FLAG, 
    UNMATCHED_KEY_OR_INDEX, 
    USER_CHKSUM_MISMATCH, 
    USER_BAD_KEYWORD_ERR, 
    USER__NULL_INPUT_ERR, 
    USER_INPUT_PATH_ERR, 
    USER_INPUT_OPTION_ERR, 
    USER_INVALID_USERNAME_FORMAT, 
    USER_DIRECT_RESC_INPUT_ERR, 
    USER_NO_RESC_INPUT_ERR, 
    USER_PARAM_LABEL_ERR, 
    USER_PARAM_TYPE_ERR, 
    BASE64_BUFFER_OVERFLOW, 
    BASE64_INVALID_PACKET, 
    USER_MSG_TYPE_NO_SUPPORT, 
    USER_RSYNC_NO_MODE_INPUT_ERR, 
    USER_OPTION_INPUT_ERR, 
    SAME_SRC_DEST_PATHS_ERR, 
    USER_RESTART_FILE_INPUT_ERR, 
    RESTART_OPR_FAILED, 
    BAD_EXEC_CMD_PATH, 
    EXEC_CMD_OUTPUT_TOO_LARGE, 
    EXEC_CMD_ERROR, 
    BAD_INPUT_DESC_INDEX, 
    USER_PATH_EXCEEDS_MAX, 
    USER_SOCK_CONNECT_TIMEDOUT, 
    USER_API_VERSION_MISMATCH, 
    USER_INPUT_FORMAT_ERR, 
    USER_ACCESS_DENIED, 
    CANT_RM_MV_BUNDLE_TYPE, 
    NO_MORE_RESULT, 
    NO_KEY_WD_IN_MS_INP_STR, 
    CANT_RM_NON_EMPTY_HOME_COLL, 
    CANT_UNREG_IN_VAULT_FILE, 
    NO_LOCAL_FILE_RSYNC_IN_MSI, 
    BULK_OPR_MISMATCH_FOR_RESTART, 
    OBJ_PATH_DOES_NOT_EXIST, 
    SYMLINKED_BUNFILE_NOT_ALLOWED, 
    USER_INPUT_STRING_ERR, 
    USER_NOT_ALLOWED_TO_EXEC_CMD, 
    FILE_INDEX_LOOKUP_ERR, 
    UNIX_FILE_OPEN_ERR, 
    UNIX_FILE_CREATE_ERR, 
    UNIX_FILE_READ_ERR, 
    UNIX_FILE_WRITE_ERR, 
    UNIX_FILE_CLOSE_ERR, 
    UNIX_FILE_UNLINK_ERR, 
    UNIX_FILE_STAT_ERR, 
    UNIX_FILE_FSTAT_ERR, 
    UNIX_FILE_LSEEK_ERR, 
    UNIX_FILE_FSYNC_ERR, 
    UNIX_FILE_MKDIR_ERR, 
    UNIX_FILE_RMDIR_ERR, 
    UNIX_FILE_OPENDIR_ERR, 
    UNIX_FILE_CLOSEDIR_ERR, 
    UNIX_FILE_READDIR_ERR, 
    UNIX_FILE_STAGE_ERR, 
    UNIX_FILE_GET_FS_FREESPACE_ERR, 
    UNIX_FILE_CHMOD_ERR, 
    UNIX_FILE_RENAME_ERR, 
    UNIX_FILE_TRUNCATE_ERR, 
    UNIX_FILE_LINK_ERR, 
    UNIX_FILE_OPR_TIMEOUT_ERR, 
    UNIV_MSS_SYNCTOARCH_ERR, 
    UNIV_MSS_STAGETOCACHE_ERR, 
    UNIV_MSS_UNLINK_ERR, 
    UNIV_MSS_MKDIR_ERR, 
    UNIV_MSS_CHMOD_ERR, 
    UNIV_MSS_STAT_ERR, 
    UNIV_MSS_RENAME_ERR, 
    HPSS_AUTH_NOT_SUPPORTED, 
    HPSS_FILE_OPEN_ERR, 
    HPSS_FILE_CREATE_ERR, 
    HPSS_FILE_READ_ERR, 
    HPSS_FILE_WRITE_ERR, 
    HPSS_FILE_CLOSE_ERR, 
    HPSS_FILE_UNLINK_ERR, 
    HPSS_FILE_STAT_ERR, 
    HPSS_FILE_FSTAT_ERR, 
    HPSS_FILE_LSEEK_ERR, 
    HPSS_FILE_FSYNC_ERR, 
    HPSS_FILE_MKDIR_ERR, 
    HPSS_FILE_RMDIR_ERR, 
    HPSS_FILE_OPENDIR_ERR, 
    HPSS_FILE_CLOSEDIR_ERR, 
    HPSS_FILE_READDIR_ERR, 
    HPSS_FILE_STAGE_ERR, 
    HPSS_FILE_GET_FS_FREESPACE_ERR, 
    HPSS_FILE_CHMOD_ERR, 
    HPSS_FILE_RENAME_ERR, 
    HPSS_FILE_TRUNCATE_ERR, 
    HPSS_FILE_LINK_ERR, 
    HPSS_AUTH_ERR, 
    HPSS_WRITE_LIST_ERR, 
    HPSS_READ_LIST_ERR, 
    HPSS_TRANSFER_ERR, 
    HPSS_MOVER_PROT_ERR, 
    S3_INIT_ERROR, 
    S3_PUT_ERROR, 
    S3_GET_ERROR, 
    S3_FILE_UNLINK_ERR, 
    S3_FILE_STAT_ERR, 
    S3_FILE_COPY_ERR, 
    WOS_PUT_ERR, 
    WOS_STREAM_PUT_ERR, 
    WOS_STREAM_CLOSE_ERR, 
    WOS_GET_ERR, 
    WOS_STREAM_GET_ERR, 
    WOS_UNLINK_ERR, 
    WOS_STAT_ERR, 
    WOS_CONNECT_ERR, 
    HDFS_FILE_OPEN_ERR, 
    HDFS_FILE_CREATE_ERR, 
    HDFS_FILE_READ_ERR, 
    HDFS_FILE_WRITE_ERR, 
    HDFS_FILE_CLOSE_ERR, 
    HDFS_FILE_UNLINK_ERR, 
    HDFS_FILE_STAT_ERR, 
    HDFS_FILE_FSTAT_ERR, 
    HDFS_FILE_LSEEK_ERR, 
    HDFS_FILE_FSYNC_ERR, 
    HDFS_FILE_MKDIR_ERR, 
    HDFS_FILE_RMDIR_ERR, 
    HDFS_FILE_OPENDIR_ERR, 
    HDFS_FILE_CLOSEDIR_ERR, 
    HDFS_FILE_READDIR_ERR, 
    HDFS_FILE_STAGE_ERR, 
    HDFS_FILE_GET_FS_FREESPACE_ERR, 
    HDFS_FILE_CHMOD_ERR, 
    HDFS_FILE_RENAME_ERR, 
    HDFS_FILE_TRUNCATE_ERR, 
    HDFS_FILE_LINK_ERR, 
    HDFS_FILE_OPR_TIMEOUT_ERR, 
    DIRECT_ACCESS_FILE_USER_INVALID_ERR, 
    CATALOG_NOT_CONNECTED, 
    CAT_ENV_ERR, 
    CAT_CONNECT_ERR, 
    CAT_DISCONNECT_ERR, 
    CAT_CLOSE_ENV_ERR, 
    CAT_SQL_ERR, 
    CAT_GET_ROW_ERR, 
    CAT_NO_ROWS_FOUND, 
    CATALOG_ALREADY_HAS_ITEM_BY_THAT_NAME, 
    CAT_INVALID_RESOURCE_TYPE, 
    CAT_INVALID_RESOURCE_CLASS, 
    CAT_INVALID_RESOURCE_NET_ADDR, 
    CAT_INVALID_RESOURCE_VAULT_PATH, 
    CAT_UNKNOWN_COLLECTION, 
    CAT_INVALID_DATA_TYPE, 
    CAT_INVALID_ARGUMENT, 
    CAT_UNKNOWN_FILE, 
    CAT_NO_ACCESS_PERMISSION, 
    CAT_SUCCESS_BUT_WITH_NO_INFO, 
    CAT_INVALID_USER_TYPE, 
    CAT_COLLECTION_NOT_EMPTY, 
    CAT_TOO_MANY_TABLES, 
    CAT_UNKNOWN_TABLE, 
    CAT_NOT_OPEN, 
    CAT_FAILED_TO_LINK_TABLES, 
    CAT_INVALID_AUTHENTICATION, 
    CAT_INVALID_USER, 
    CAT_INVALID_ZONE, 
    CAT_INVALID_GROUP, 
    CAT_INSUFFICIENT_PRIVILEGE_LEVEL, 
    CAT_INVALID_RESOURCE, 
    CAT_INVALID_CLIENT_USER, 
    CAT_NAME_EXISTS_AS_COLLECTION, 
    CAT_NAME_EXISTS_AS_DATAOBJ, 
    CAT_RESOURCE_NOT_EMPTY, 
    CAT_NOT_A_DATAOBJ_AND_NOT_A_COLLECTION, 
    CAT_RECURSIVE_MOVE, 
    CAT_LAST_REPLICA, 
    CAT_OCI_ERROR, 
    CAT_PASSWORD_EXPIRED, 
    CAT_PASSWORD_ENCODING_ERROR, 
    CAT_TABLE_ACCESS_DENIED, 
    CAT_UNKNOWN_RESOURCE, 
    CAT_UNKNOWN_SPECIFIC_QUERY, 
    CAT_PSEUDO_RESC_MODIFY_DISALLOWED, 
    CAT_HOSTNAME_INVALID, 
    CAT_BIND_VARIABLE_LIMIT_EXCEEDED, 
    RDA_NOT_COMPILED_IN, 
    RDA_NOT_CONNECTED, 
    RDA_ENV_ERR, 
    RDA_CONNECT_ERR, 
    RDA_DISCONNECT_ERR, 
    RDA_CLOSE_ENV_ERR, 
    RDA_SQL_ERR, 
    RDA_CONFIG_FILE_ERR, 
    RDA_ACCESS_PROHIBITED, 
    RDA_NAME_NOT_FOUND, 
    CAT_TICKET_INVALID, 
    CAT_TICKET_EXPIRED, 
    CAT_TICKET_USES_EXCEEDED, 
    CAT_TICKET_USER_EXCLUDED, 
    CAT_TICKET_HOST_EXCLUDED, 
    CAT_TICKET_GROUP_EXCLUDED, 
    CAT_TICKET_WRITE_USES_EXCEEDED, 
    CAT_TICKET_WRITE_BYTES_EXCEEDED, 
    FILE_OPEN_ERR, 
    FILE_READ_ERR, 
    FILE_WRITE_ERR, 
    PASSWORD_EXCEEDS_MAX_SIZE, 
    ENVIRONMENT_VAR_HOME_NOT_DEFINED, 
    UNABLE_TO_STAT_FILE, 
    AUTH_FILE_NOT_ENCRYPTED, 
    AUTH_FILE_DOES_NOT_EXIST, 
    UNLINK_FAILED, 
    NO_PASSWORD_ENTERED, 
    REMOTE_SERVER_AUTHENTICATION_FAILURE, 
    REMOTE_SERVER_AUTH_NOT_PROVIDED, 
    REMOTE_SERVER_AUTH_EMPTY, 
    REMOTE_SERVER_SID_NOT_DEFINED, 
    UNSUPPORTED_HASH_TYPE_USED, 
    GSI_NOT_COMPILED_IN, 
    GSI_NOT_BUILT_INTO_CLIENT, 
    GSI_NOT_BUILT_INTO_SERVER, 
    GSI_ERROR_IMPORT_NAME, 
    GSI_ERROR_INIT_SECURITY_CONTEXT, 
    GSI_ERROR_SENDING_TOKEN_LENGTH, 
    GSI_ERROR_READING_TOKEN_LENGTH, 
    GSI_ERROR_TOKEN_TOO_LARGE, 
    GSI_ERROR_BAD_TOKEN_RCVED, 
    GSI_SOCKET_READ_ERROR, 
    GSI_PARTIAL_TOKEN_READ, 
    GSI_SOCKET_WRITE_ERROR, 
    GSI_ERROR_FROM_GSI_LIBRARY, 
    GSI_ERROR_IMPORTING_NAME, 
    GSI_ERROR_ACQUIRING_CREDS, 
    GSI_ACCEPT_SEC_CONTEXT_ERROR, 
    GSI_ERROR_DISPLAYING_NAME, 
    GSI_ERROR_RELEASING_NAME, 
    GSI_DN_DOES_NOT_MATCH_USER, 
    GSI_QUERY_INTERNAL_ERROR, 
    GSI_NO_MATCHING_DN_FOUND, 
    GSI_MULTIPLE_MATCHING_DN_FOUND, 
    KRB_NOT_COMPILED_IN, 
    KRB_NOT_BUILT_INTO_CLIENT, 
    KRB_NOT_BUILT_INTO_SERVER, 
    KRB_ERROR_IMPORT_NAME, 
    KRB_ERROR_INIT_SECURITY_CONTEXT, 
    KRB_ERROR_SENDING_TOKEN_LENGTH, 
    KRB_ERROR_READING_TOKEN_LENGTH, 
    KRB_ERROR_TOKEN_TOO_LARGE, 
    KRB_ERROR_BAD_TOKEN_RCVED, 
    KRB_SOCKET_READ_ERROR, 
    KRB_PARTIAL_TOKEN_READ, 
    KRB_SOCKET_WRITE_ERROR, 
    KRB_ERROR_FROM_KRB_LIBRARY, 
    KRB_ERROR_IMPORTING_NAME, 
    KRB_ERROR_ACQUIRING_CREDS, 
    KRB_ACCEPT_SEC_CONTEXT_ERROR, 
    KRB_ERROR_DISPLAYING_NAME, 
    KRB_ERROR_RELEASING_NAME, 
    KRB_USER_DN_NOT_FOUND, 
    KRB_NAME_MATCHES_MULTIPLE_USERS, 
    KRB_QUERY_INTERNAL_ERROR, 
    OSAUTH_NOT_BUILT_INTO_CLIENT, 
    OSAUTH_NOT_BUILT_INTO_SERVER, 
    PAM_AUTH_NOT_BUILT_INTO_CLIENT, 
    PAM_AUTH_NOT_BUILT_INTO_SERVER, 
    PAM_AUTH_PASSWORD_FAILED, 
    PAM_AUTH_PASSWORD_INVALID_TTL, 
    OBJPATH_EMPTY_IN_STRUCT_ERR, 
    RESCNAME_EMPTY_IN_STRUCT_ERR, 
    DATATYPE_EMPTY_IN_STRUCT_ERR, 
    DATASIZE_EMPTY_IN_STRUCT_ERR, 
    CHKSUM_EMPTY_IN_STRUCT_ERR, 
    VERSION_EMPTY_IN_STRUCT_ERR, 
    FILEPATH_EMPTY_IN_STRUCT_ERR, 
    REPLNUM_EMPTY_IN_STRUCT_ERR, 
    REPLSTATUS_EMPTY_IN_STRUCT_ERR, 
    DATAOWNER_EMPTY_IN_STRUCT_ERR, 
    DATAOWNERZONE_EMPTY_IN_STRUCT_ERR, 
    DATAEXPIRY_EMPTY_IN_STRUCT_ERR, 
    DATACOMMENTS_EMPTY_IN_STRUCT_ERR, 
    DATACREATE_EMPTY_IN_STRUCT_ERR, 
    DATAMODIFY_EMPTY_IN_STRUCT_ERR, 
    DATAACCESS_EMPTY_IN_STRUCT_ERR, 
    DATAACCESSINX_EMPTY_IN_STRUCT_ERR, 
    NO_RULE_FOUND_ERR, 
    NO_MORE_RULES_ERR, 
    UNMATCHED_ACTION_ERR, 
    RULES_FILE_READ_ERROR, 
    ACTION_ARG_COUNT_MISMATCH, 
    MAX_NUM_OF_ARGS_IN_ACTION_EXCEEDED, 
    UNKNOWN_PARAM_IN_RULE_ERR, 
    DESTRESCNAME_EMPTY_IN_STRUCT_ERR, 
    BACKUPRESCNAME_EMPTY_IN_STRUCT_ERR, 
    DATAID_EMPTY_IN_STRUCT_ERR, 
    COLLID_EMPTY_IN_STRUCT_ERR, 
    RESCGROUPNAME_EMPTY_IN_STRUCT_ERR, 
    STATUSSTRING_EMPTY_IN_STRUCT_ERR, 
    DATAMAPID_EMPTY_IN_STRUCT_ERR, 
    USERNAMECLIENT_EMPTY_IN_STRUCT_ERR, 
    RODSZONECLIENT_EMPTY_IN_STRUCT_ERR, 
    USERTYPECLIENT_EMPTY_IN_STRUCT_ERR, 
    HOSTCLIENT_EMPTY_IN_STRUCT_ERR, 
    AUTHSTRCLIENT_EMPTY_IN_STRUCT_ERR, 
    USERAUTHSCHEMECLIENT_EMPTY_IN_STRUCT_ERR, 
    USERINFOCLIENT_EMPTY_IN_STRUCT_ERR, 
    USERCOMMENTCLIENT_EMPTY_IN_STRUCT_ERR, 
    USERCREATECLIENT_EMPTY_IN_STRUCT_ERR, 
    USERMODIFYCLIENT_EMPTY_IN_STRUCT_ERR, 
    USERNAMEPROXY_EMPTY_IN_STRUCT_ERR, 
    RODSZONEPROXY_EMPTY_IN_STRUCT_ERR, 
    USERTYPEPROXY_EMPTY_IN_STRUCT_ERR, 
    HOSTPROXY_EMPTY_IN_STRUCT_ERR, 
    AUTHSTRPROXY_EMPTY_IN_STRUCT_ERR, 
    USERAUTHSCHEMEPROXY_EMPTY_IN_STRUCT_ERR, 
    USERINFOPROXY_EMPTY_IN_STRUCT_ERR, 
    USERCOMMENTPROXY_EMPTY_IN_STRUCT_ERR, 
    USERCREATEPROXY_EMPTY_IN_STRUCT_ERR, 
    USERMODIFYPROXY_EMPTY_IN_STRUCT_ERR, 
    COLLNAME_EMPTY_IN_STRUCT_ERR, 
    COLLPARENTNAME_EMPTY_IN_STRUCT_ERR, 
    COLLOWNERNAME_EMPTY_IN_STRUCT_ERR, 
    COLLOWNERZONE_EMPTY_IN_STRUCT_ERR, 
    COLLEXPIRY_EMPTY_IN_STRUCT_ERR, 
    COLLCOMMENTS_EMPTY_IN_STRUCT_ERR, 
    COLLCREATE_EMPTY_IN_STRUCT_ERR, 
    COLLMODIFY_EMPTY_IN_STRUCT_ERR, 
    COLLACCESS_EMPTY_IN_STRUCT_ERR, 
    COLLACCESSINX_EMPTY_IN_STRUCT_ERR, 
    COLLMAPID_EMPTY_IN_STRUCT_ERR, 
    COLLINHERITANCE_EMPTY_IN_STRUCT_ERR, 
    RESCZONE_EMPTY_IN_STRUCT_ERR, 
    RESCLOC_EMPTY_IN_STRUCT_ERR, 
    RESCTYPE_EMPTY_IN_STRUCT_ERR, 
    RESCTYPEINX_EMPTY_IN_STRUCT_ERR, 
    RESCCLASS_EMPTY_IN_STRUCT_ERR, 
    RESCCLASSINX_EMPTY_IN_STRUCT_ERR, 
    RESCVAULTPATH_EMPTY_IN_STRUCT_ERR, 
    NUMOPEN_ORTS_EMPTY_IN_STRUCT_ERR, 
    PARAOPR_EMPTY_IN_STRUCT_ERR, 
    RESCID_EMPTY_IN_STRUCT_ERR, 
    GATEWAYADDR_EMPTY_IN_STRUCT_ERR, 
    RESCMAX_BJSIZE_EMPTY_IN_STRUCT_ERR, 
    FREESPACE_EMPTY_IN_STRUCT_ERR, 
    FREESPACETIME_EMPTY_IN_STRUCT_ERR, 
    FREESPACETIMESTAMP_EMPTY_IN_STRUCT_ERR, 
    RESCINFO_EMPTY_IN_STRUCT_ERR, 
    RESCCOMMENTS_EMPTY_IN_STRUCT_ERR, 
    RESCCREATE_EMPTY_IN_STRUCT_ERR, 
    RESCMODIFY_EMPTY_IN_STRUCT_ERR, 
    INPUT_ARG_NOT_WELL_FORMED_ERR, 
    INPUT_ARG_OUT_OF_ARGC_RANGE_ERR, 
    INSUFFICIENT_INPUT_ARG_ERR, 
    INPUT_ARG_DOES_NOT_MATCH_ERR, 
    RETRY_WITHOUT_RECOVERY_ERR, 
    CUT_ACTION_PROCESSED_ERR, 
    ACTION_FAILED_ERR, 
    FAIL_ACTION_ENCOUNTERED_ERR, 
    VARIABLE_NAME_TOO_LONG_ERR, 
    UNKNOWN_VARIABLE_MAP_ERR, 
    UNDEFINED_VARIABLE_MAP_ERR, 
    NULL_VALUE_ERR, 
    DVARMAP_FILE_READ_ERROR, 
    NO_RULE_OR_MSI_FUNCTION_FOUND_ERR, 
    FILE_CREATE_ERROR, 
    FMAP_FILE_READ_ERROR, 
    DATE_FORMAT_ERR, 
    RULE_FAILED_ERR, 
    NO_MICROSERVICE_FOUND_ERR, 
    INVALID_REGEXP, 
    INVALID_OBJECT_NAME, 
    INVALID_OBJECT_TYPE, 
    NO_VALUES_FOUND, 
    NO_COLUMN_NAME_FOUND, 
    BREAK_ACTION_ENCOUNTERED_ERR, 
    CUT_ACTION_ON_SUCCESS_PROCESSED_ERR, 
    MSI_OPERATION_NOT_ALLOWED, 
    MAX_NUM_OF_ACTION_IN_RULE_EXCEEDED, 
    MSRVC_FILE_READ_ERROR, 
    MSRVC_VERSION_MISMATCH, 
    MICRO_SERVICE_OBJECT_TYPE_UNDEFINED, 
    MSO_OBJ_GET_FAILED, 
    REMOTE_IRODS_CONNECT_ERR, 
    REMOTE_SRB_CONNECT_ERR, 
    MSO_OBJ_PUT_FAILED, 
    RE_PARSER_ERROR, 
    RE_UNPARSED_SUFFIX, 
    RE_POINTER_ERROR, 
    RE_RUNTIME_ERROR, 
    RE_DIVISION_BY_ZERO, 
    RE_BUFFER_OVERFLOW, 
    RE_UNSUPPORTED_OP_OR_TYPE, 
    RE_UNSUPPORTED_SESSION_VAR, 
    RE_UNABLE_TO_WRITE_LOCAL_VAR, 
    RE_UNABLE_TO_READ_LOCAL_VAR, 
    RE_UNABLE_TO_WRITE_SESSION_VAR, 
    RE_UNABLE_TO_READ_SESSION_VAR, 
    RE_UNABLE_TO_WRITE_VAR, 
    RE_UNABLE_TO_READ_VAR, 
    RE_PATTERN_NOT_MATCHED, 
    RE_STRING_OVERFLOW, 
    RE_UNKNOWN_ERROR, 
    RE_OUT_OF_MEMORY, 
    RE_SHM_UNLINK_ERROR, 
    RE_FILE_STAT_ERROR, 
    RE_UNSUPPORTED_AST_NODE_TYPE, 
    RE_UNSUPPORTED_SESSION_VAR_TYPE, 
    RE_TYPE_ERROR, 
    RE_FUNCTION_REDEFINITION, 
    RE_DYNAMIC_TYPE_ERROR, 
    RE_DYNAMIC_COERCION_ERROR, 
    RE_PACKING_ERROR, 
    PHP_EXEC_SCRIPT_ERR, 
    PHP_REQUEST_STARTUP_ERR, 
    PHP_OPEN_SCRIPT_FILE_ERR, 
    DBR_NOT_COMPILED_IN, 
    DBR_ENV_ERR, 
    DBR_CONNECT_ERR, 
    DBR_DISCONNECT_ERR, 
    DBR_CLOSE_ENV_ERR, 
    DBO_SQL_ERR, 
    DBR_CONFIG_FILE_ERR, 
    DBR_MAX_SESSIONS_REACHED, 
    DBR_NOT_OPEN, 
    DBR_NAME_NOT_FOUND, 
    DBO_INVALID_CONTROL_OPTION, 
    DBR_ALREADY_OPEN, 
    DBO_DOES_NOT_EXIST, 
    DBR_ACCESS_PROHIBITED, 
    DBO_NOT_VALID_DATATYPE, 
    DBR_WRITABLE_BY_TOO_MANY, 
    DBO_WRITABLE_BY_TOO_MANY, 
    DBO_WRITABLE_BY_NON_PRIVILEGED, 
    NETCDF_OPEN_ERR, 
    NETCDF_CREATE_ERR, 
    NETCDF_CLOSE_ERR, 
    NETCDF_INVALID_PARAM_TYPE, 
    NETCDF_INQ_ID_ERR, 
    NETCDF_GET_VARS_ERR, 
    NETCDF_INVALID_DATA_TYPE, 
    NETCDF_INQ_VARS_ERR, 
    NETCDF_VARS_DATA_TOO_BIG, 
    NETCDF_DIM_MISMATCH_ERR, 
    NETCDF_INQ_ERR, 
    NETCDF_INQ_FORMAT_ERR, 
    NETCDF_INQ_DIM_ERR, 
    NETCDF_INQ_ATT_ERR, 
    NETCDF_GET_ATT_ERR, 
    NETCDF_VAR_COUNT_OUT_OF_RANGE, 
    NETCDF_UNMATCHED_NAME_ERR, 
    NETCDF_NO_UNLIMITED_DIM, 
    NETCDF_PUT_ATT_ERR, 
    NETCDF_DEF_DIM_ERR, 
    NETCDF_DEF_VAR_ERR, 
    NETCDF_PUT_VARS_ERR, 
    NETCDF_AGG_INFO_FILE_ERR, 
    NETCDF_AGG_ELE_INX_OUT_OF_RANGE, 
    NETCDF_AGG_ELE_FILE_NOT_OPENED, 
    NETCDF_AGG_ELE_FILE_NO_TIME_DIM, 
    NETCDF_BUILD_WITH_NETCDF_API_NEEDED, 
    SSL_NOT_BUILT_INTO_CLIENT, 
    SSL_NOT_BUILT_INTO_SERVER, 
    SSL_INIT_ERROR, 
    SSL_HANDSHAKE_ERROR, 
    SSL_SHUTDOWN_ERROR, 
    SSL_CERT_ERROR, 
    OOI_CURL_EASY_INIT_ERR, 
    OOI_JSON_OBJ_SET_ERR, 
    OOI_DICT_TYPE_NOT_SUPPORTED, 
    OOI_JSON_PACK_ERR, 
    OOI_JSON_DUMP_ERR, 
    OOI_CURL_EASY_PERFORM_ERR, 
    OOI_JSON_LOAD_ERR, 
    OOI_JSON_GET_ERR, 
    OOI_JSON_NO_ANSWER_ERR, 
    OOI_JSON_TYPE_ERR, 
    OOI_JSON_INX_OUT_OF_RANGE, 
    OOI_REVID_NOT_FOUND, 
    XML_PARSING_ERR, 
    OUT_OF_URL_PATH, 
    URL_PATH_INX_OUT_OF_RANGE, 
    SYS_NULL_INPUT, 
    SYS_HANDLER_DONE_WITH_ERROR, 
    SYS_HANDLER_DONE_NO_ERROR, 
    SYS_NO_HANDLER_REPLY_MSG, 
};
   char *irodsErrorNames[]={ 
    "SYS_SOCK_OPEN_ERR", 
    "SYS_SOCK_BIND_ERR", 
    "SYS_SOCK_ACCEPT_ERR", 
    "SYS_HEADER_READ_LEN_ERR", 
    "SYS_HEADER_WRITE_LEN_ERR", 
    "SYS_HEADER_TPYE_LEN_ERR", 
    "SYS_CAUGHT_SIGNAL", 
    "SYS_GETSTARTUP_PACK_ERR", 
    "SYS_EXCEED_CONNECT_CNT", 
    "SYS_USER_NOT_ALLOWED_TO_CONN", 
    "SYS_READ_MSG_BODY_INPUT_ERR", 
    "SYS_UNMATCHED_API_NUM", 
    "SYS_NO_API_PRIV", 
    "SYS_API_INPUT_ERR", 
    "SYS_PACK_INSTRUCT_FORMAT_ERR", 
    "SYS_MALLOC_ERR", 
    "SYS_GET_HOSTNAME_ERR", 
    "SYS_OUT_OF_FILE_DESC", 
    "SYS_FILE_DESC_OUT_OF_RANGE", 
    "SYS_UNRECOGNIZED_REMOTE_FLAG", 
    "SYS_INVALID_SERVER_HOST", 
    "SYS_SVR_TO_SVR_CONNECT_FAILED", 
    "SYS_BAD_FILE_DESCRIPTOR", 
    "SYS_INTERNAL_NULL_INPUT_ERR", 
    "SYS_CONFIG_FILE_ERR", 
    "SYS_INVALID_ZONE_NAME", 
    "SYS_COPY_LEN_ERR", 
    "SYS_PORT_COOKIE_ERR", 
    "SYS_KEY_VAL_TABLE_ERR", 
    "SYS_INVALID_RESC_TYPE", 
    "SYS_INVALID_FILE_PATH", 
    "SYS_INVALID_RESC_INPUT", 
    "SYS_INVALID_PORTAL_OPR", 
    "SYS_PARA_OPR_NO_SUPPORT", 
    "SYS_INVALID_OPR_TYPE", 
    "SYS_NO_PATH_PERMISSION", 
    "SYS_NO_ICAT_SERVER_ERR", 
    "SYS_AGENT_INIT_ERR", 
    "SYS_PROXYUSER_NO_PRIV", 
    "SYS_NO_DATA_OBJ_PERMISSION", 
    "SYS_DELETE_DISALLOWED", 
    "SYS_OPEN_REI_FILE_ERR", 
    "SYS_NO_RCAT_SERVER_ERR", 
    "SYS_UNMATCH_PACK_INSTRUCTI_NAME", 
    "SYS_SVR_TO_CLI_MSI_NO_EXIST", 
    "SYS_COPY_ALREADY_IN_RESC", 
    "SYS_RECONN_OPR_MISMATCH", 
    "SYS_INPUT_PERM_OUT_OF_RANGE", 
    "SYS_FORK_ERROR", 
    "SYS_PIPE_ERROR", 
    "SYS_EXEC_CMD_STATUS_SZ_ERROR", 
    "SYS_PATH_IS_NOT_A_FILE", 
    "SYS_UNMATCHED_SPEC_COLL_TYPE", 
    "SYS_TOO_MANY_QUERY_RESULT", 
    "SYS_SPEC_COLL_NOT_IN_CACHE", 
    "SYS_SPEC_COLL_OBJ_NOT_EXIST", 
    "SYS_REG_OBJ_IN_SPEC_COLL", 
    "SYS_DEST_SPEC_COLL_SUB_EXIST", 
    "SYS_SRC_DEST_SPEC_COLL_CONFLICT", 
    "SYS_UNKNOWN_SPEC_COLL_CLASS", 
    "SYS_DUPLICATE_XMSG_TICKET", 
    "SYS_UNMATCHED_XMSG_TICKET", 
    "SYS_NO_XMSG_FOR_MSG_NUMBER", 
    "SYS_COLLINFO_2_FORMAT_ERR", 
    "SYS_CACHE_STRUCT_FILE_RESC_ERR", 
    "SYS_NOT_SUPPORTED", 
    "SYS_TAR_STRUCT_FILE_EXTRACT_ERR", 
    "SYS_STRUCT_FILE_DESC_ERR", 
    "SYS_TAR_OPEN_ERR", 
    "SYS_TAR_EXTRACT_ALL_ERR", 
    "SYS_TAR_CLOSE_ERR", 
    "SYS_STRUCT_FILE_PATH_ERR", 
    "SYS_MOUNT_MOUNTED_COLL_ERR", 
    "SYS_COLL_NOT_MOUNTED_ERR", 
    "SYS_STRUCT_FILE_BUSY_ERR", 
    "SYS_STRUCT_FILE_INMOUNTED_COLL", 
    "SYS_COPY_NOT_EXIST_IN_RESC", 
    "SYS_RESC_DOES_NOT_EXIST", 
    "SYS_COLLECTION_NOT_EMPTY", 
    "SYS_OBJ_TYPE_NOT_STRUCT_FILE", 
    "SYS_WRONG_RESC_POLICY_FOR_BUN_OPR", 
    "SYS_DIR_IN_VAULT_NOT_EMPTY", 
    "SYS_OPR_FLAG_NOT_SUPPORT", 
    "SYS_TAR_APPEND_ERR", 
    "SYS_INVALID_PROTOCOL_TYPE", 
    "SYS_UDP_CONNECT_ERR", 
    "SYS_UDP_TRANSFER_ERR", 
    "SYS_UDP_NO_SUPPORT_ERR", 
    "SYS_READ_MSG_BODY_LEN_ERR", 
    "CROSS_ZONE_SOCK_CONNECT_ERR", 
    "SYS_NO_FREE_RE_THREAD", 
    "SYS_BAD_RE_THREAD_INX", 
    "SYS_CANT_DIRECTLY_ACC_COMPOUND_RESC", 
    "SYS_SRC_DEST_RESC_COMPOUND_TYPE", 
    "SYS_CACHE_RESC_NOT_ON_SAME_HOST", 
    "SYS_NO_CACHE_RESC_IN_GRP", 
    "SYS_UNMATCHED_RESC_IN_RESC_GRP", 
    "SYS_CANT_MV_BUNDLE_DATA_TO_TRASH", 
    "SYS_CANT_MV_BUNDLE_DATA_BY_COPY", 
    "SYS_EXEC_TAR_ERR", 
    "SYS_CANT_CHKSUM_COMP_RESC_DATA", 
    "SYS_CANT_CHKSUM_BUNDLED_DATA", 
    "SYS_RESC_IS_DOWN", 
    "SYS_UPDATE_REPL_INFO_ERR", 
    "SYS_COLL_LINK_PATH_ERR", 
    "SYS_LINK_CNT_EXCEEDED_ERR", 
    "SYS_CROSS_ZONE_MV_NOT_SUPPORTED", 
    "SYS_RESC_QUOTA_EXCEEDED", 
    "SYS_RENAME_STRUCT_COUNT_EXCEEDED", 
    "SYS_BULK_REG_COUNT_EXCEEDED", 
    "SYS_REQUESTED_BUF_TOO_LARGE", 
    "SYS_INVALID_RESC_FOR_BULK_OPR", 
    "SYS_SOCK_READ_TIMEDOUT", 
    "SYS_SOCK_READ_ERR", 
    "SYS_CONNECT_CONTROL_CONFIG_ERR", 
    "SYS_MAX_CONNECT_COUNT_EXCEEDED", 
    "SYS_STRUCT_ELEMENT_MISMATCH", 
    "SYS_PHY_PATH_INUSE", 
    "SYS_USER_NO_PERMISSION", 
    "SYS_USER_RETRIEVE_ERR", 
    "SYS_FS_LOCK_ERR", 
    "SYS_LOCK_TYPE_INP_ERR", 
    "SYS_LOCK_CMD_INP_ERR", 
    "SYS_ZIP_FORMAT_NOT_SUPPORTED", 
    "SYS_ADD_TO_ARCH_OPR_NOT_SUPPORTED", 
    "CANT_REG_IN_VAULT_FILE", 
    "PATH_REG_NOT_ALLOWED", 
    "SYS_INVALID_INPUT_PARAM", 
    "SYS_GROUP_RETRIEVE_ERR", 
    "SYS_MSSO_APPEND_ERR", 
    "SYS_MSSO_STRUCT_FILE_EXTRACT_ERR", 
    "SYS_MSSO_EXTRACT_ALL_ERR", 
    "SYS_MSSO_OPEN_ERR", 
    "SYS_MSSO_CLOSE_ERR", 
    "USER_AUTH_SCHEME_ERR", 
    "USER_AUTH_STRING_EMPTY", 
    "USER_RODS_HOST_EMPTY", 
    "USER_RODS_HOSTNAME_ERR", 
    "USER_SOCK_OPEN_ERR", 
    "USER_SOCK_CONNECT_ERR", 
    "USER_STRLEN_TOOLONG", 
    "USER_API_INPUT_ERR", 
    "USER_PACKSTRUCT_INPUT_ERR", 
    "USER_NO_SUPPORT_ERR", 
    "USER_FILE_DOES_NOT_EXIST", 
    "USER_FILE_TOO_LARGE", 
    "OVERWRITE_WITHOUT_FORCE_FLAG", 
    "UNMATCHED_KEY_OR_INDEX", 
    "USER_CHKSUM_MISMATCH", 
    "USER_BAD_KEYWORD_ERR", 
    "USER__NULL_INPUT_ERR", 
    "USER_INPUT_PATH_ERR", 
    "USER_INPUT_OPTION_ERR", 
    "USER_INVALID_USERNAME_FORMAT", 
    "USER_DIRECT_RESC_INPUT_ERR", 
    "USER_NO_RESC_INPUT_ERR", 
    "USER_PARAM_LABEL_ERR", 
    "USER_PARAM_TYPE_ERR", 
    "BASE64_BUFFER_OVERFLOW", 
    "BASE64_INVALID_PACKET", 
    "USER_MSG_TYPE_NO_SUPPORT", 
    "USER_RSYNC_NO_MODE_INPUT_ERR", 
    "USER_OPTION_INPUT_ERR", 
    "SAME_SRC_DEST_PATHS_ERR", 
    "USER_RESTART_FILE_INPUT_ERR", 
    "RESTART_OPR_FAILED", 
    "BAD_EXEC_CMD_PATH", 
    "EXEC_CMD_OUTPUT_TOO_LARGE", 
    "EXEC_CMD_ERROR", 
    "BAD_INPUT_DESC_INDEX", 
    "USER_PATH_EXCEEDS_MAX", 
    "USER_SOCK_CONNECT_TIMEDOUT", 
    "USER_API_VERSION_MISMATCH", 
    "USER_INPUT_FORMAT_ERR", 
    "USER_ACCESS_DENIED", 
    "CANT_RM_MV_BUNDLE_TYPE", 
    "NO_MORE_RESULT", 
    "NO_KEY_WD_IN_MS_INP_STR", 
    "CANT_RM_NON_EMPTY_HOME_COLL", 
    "CANT_UNREG_IN_VAULT_FILE", 
    "NO_LOCAL_FILE_RSYNC_IN_MSI", 
    "BULK_OPR_MISMATCH_FOR_RESTART", 
    "OBJ_PATH_DOES_NOT_EXIST", 
    "SYMLINKED_BUNFILE_NOT_ALLOWED", 
    "USER_INPUT_STRING_ERR", 
    "USER_NOT_ALLOWED_TO_EXEC_CMD", 
    "FILE_INDEX_LOOKUP_ERR", 
    "UNIX_FILE_OPEN_ERR", 
    "UNIX_FILE_CREATE_ERR", 
    "UNIX_FILE_READ_ERR", 
    "UNIX_FILE_WRITE_ERR", 
    "UNIX_FILE_CLOSE_ERR", 
    "UNIX_FILE_UNLINK_ERR", 
    "UNIX_FILE_STAT_ERR", 
    "UNIX_FILE_FSTAT_ERR", 
    "UNIX_FILE_LSEEK_ERR", 
    "UNIX_FILE_FSYNC_ERR", 
    "UNIX_FILE_MKDIR_ERR", 
    "UNIX_FILE_RMDIR_ERR", 
    "UNIX_FILE_OPENDIR_ERR", 
    "UNIX_FILE_CLOSEDIR_ERR", 
    "UNIX_FILE_READDIR_ERR", 
    "UNIX_FILE_STAGE_ERR", 
    "UNIX_FILE_GET_FS_FREESPACE_ERR", 
    "UNIX_FILE_CHMOD_ERR", 
    "UNIX_FILE_RENAME_ERR", 
    "UNIX_FILE_TRUNCATE_ERR", 
    "UNIX_FILE_LINK_ERR", 
    "UNIX_FILE_OPR_TIMEOUT_ERR", 
    "UNIV_MSS_SYNCTOARCH_ERR", 
    "UNIV_MSS_STAGETOCACHE_ERR", 
    "UNIV_MSS_UNLINK_ERR", 
    "UNIV_MSS_MKDIR_ERR", 
    "UNIV_MSS_CHMOD_ERR", 
    "UNIV_MSS_STAT_ERR", 
    "UNIV_MSS_RENAME_ERR", 
    "HPSS_AUTH_NOT_SUPPORTED", 
    "HPSS_FILE_OPEN_ERR", 
    "HPSS_FILE_CREATE_ERR", 
    "HPSS_FILE_READ_ERR", 
    "HPSS_FILE_WRITE_ERR", 
    "HPSS_FILE_CLOSE_ERR", 
    "HPSS_FILE_UNLINK_ERR", 
    "HPSS_FILE_STAT_ERR", 
    "HPSS_FILE_FSTAT_ERR", 
    "HPSS_FILE_LSEEK_ERR", 
    "HPSS_FILE_FSYNC_ERR", 
    "HPSS_FILE_MKDIR_ERR", 
    "HPSS_FILE_RMDIR_ERR", 
    "HPSS_FILE_OPENDIR_ERR", 
    "HPSS_FILE_CLOSEDIR_ERR", 
    "HPSS_FILE_READDIR_ERR", 
    "HPSS_FILE_STAGE_ERR", 
    "HPSS_FILE_GET_FS_FREESPACE_ERR", 
    "HPSS_FILE_CHMOD_ERR", 
    "HPSS_FILE_RENAME_ERR", 
    "HPSS_FILE_TRUNCATE_ERR", 
    "HPSS_FILE_LINK_ERR", 
    "HPSS_AUTH_ERR", 
    "HPSS_WRITE_LIST_ERR", 
    "HPSS_READ_LIST_ERR", 
    "HPSS_TRANSFER_ERR", 
    "HPSS_MOVER_PROT_ERR", 
    "S3_INIT_ERROR", 
    "S3_PUT_ERROR", 
    "S3_GET_ERROR", 
    "S3_FILE_UNLINK_ERR", 
    "S3_FILE_STAT_ERR", 
    "S3_FILE_COPY_ERR", 
    "WOS_PUT_ERR", 
    "WOS_STREAM_PUT_ERR", 
    "WOS_STREAM_CLOSE_ERR", 
    "WOS_GET_ERR", 
    "WOS_STREAM_GET_ERR", 
    "WOS_UNLINK_ERR", 
    "WOS_STAT_ERR", 
    "WOS_CONNECT_ERR", 
    "HDFS_FILE_OPEN_ERR", 
    "HDFS_FILE_CREATE_ERR", 
    "HDFS_FILE_READ_ERR", 
    "HDFS_FILE_WRITE_ERR", 
    "HDFS_FILE_CLOSE_ERR", 
    "HDFS_FILE_UNLINK_ERR", 
    "HDFS_FILE_STAT_ERR", 
    "HDFS_FILE_FSTAT_ERR", 
    "HDFS_FILE_LSEEK_ERR", 
    "HDFS_FILE_FSYNC_ERR", 
    "HDFS_FILE_MKDIR_ERR", 
    "HDFS_FILE_RMDIR_ERR", 
    "HDFS_FILE_OPENDIR_ERR", 
    "HDFS_FILE_CLOSEDIR_ERR", 
    "HDFS_FILE_READDIR_ERR", 
    "HDFS_FILE_STAGE_ERR", 
    "HDFS_FILE_GET_FS_FREESPACE_ERR", 
    "HDFS_FILE_CHMOD_ERR", 
    "HDFS_FILE_RENAME_ERR", 
    "HDFS_FILE_TRUNCATE_ERR", 
    "HDFS_FILE_LINK_ERR", 
    "HDFS_FILE_OPR_TIMEOUT_ERR", 
    "DIRECT_ACCESS_FILE_USER_INVALID_ERR", 
    "CATALOG_NOT_CONNECTED", 
    "CAT_ENV_ERR", 
    "CAT_CONNECT_ERR", 
    "CAT_DISCONNECT_ERR", 
    "CAT_CLOSE_ENV_ERR", 
    "CAT_SQL_ERR", 
    "CAT_GET_ROW_ERR", 
    "CAT_NO_ROWS_FOUND", 
    "CATALOG_ALREADY_HAS_ITEM_BY_THAT_NAME", 
    "CAT_INVALID_RESOURCE_TYPE", 
    "CAT_INVALID_RESOURCE_CLASS", 
    "CAT_INVALID_RESOURCE_NET_ADDR", 
    "CAT_INVALID_RESOURCE_VAULT_PATH", 
    "CAT_UNKNOWN_COLLECTION", 
    "CAT_INVALID_DATA_TYPE", 
    "CAT_INVALID_ARGUMENT", 
    "CAT_UNKNOWN_FILE", 
    "CAT_NO_ACCESS_PERMISSION", 
    "CAT_SUCCESS_BUT_WITH_NO_INFO", 
    "CAT_INVALID_USER_TYPE", 
    "CAT_COLLECTION_NOT_EMPTY", 
    "CAT_TOO_MANY_TABLES", 
    "CAT_UNKNOWN_TABLE", 
    "CAT_NOT_OPEN", 
    "CAT_FAILED_TO_LINK_TABLES", 
    "CAT_INVALID_AUTHENTICATION", 
    "CAT_INVALID_USER", 
    "CAT_INVALID_ZONE", 
    "CAT_INVALID_GROUP", 
    "CAT_INSUFFICIENT_PRIVILEGE_LEVEL", 
    "CAT_INVALID_RESOURCE", 
    "CAT_INVALID_CLIENT_USER", 
    "CAT_NAME_EXISTS_AS_COLLECTION", 
    "CAT_NAME_EXISTS_AS_DATAOBJ", 
    "CAT_RESOURCE_NOT_EMPTY", 
    "CAT_NOT_A_DATAOBJ_AND_NOT_A_COLLECTION", 
    "CAT_RECURSIVE_MOVE", 
    "CAT_LAST_REPLICA", 
    "CAT_OCI_ERROR", 
    "CAT_PASSWORD_EXPIRED", 
    "CAT_PASSWORD_ENCODING_ERROR", 
    "CAT_TABLE_ACCESS_DENIED", 
    "CAT_UNKNOWN_RESOURCE", 
    "CAT_UNKNOWN_SPECIFIC_QUERY", 
    "CAT_PSEUDO_RESC_MODIFY_DISALLOWED", 
    "CAT_HOSTNAME_INVALID", 
    "CAT_BIND_VARIABLE_LIMIT_EXCEEDED", 
    "RDA_NOT_COMPILED_IN", 
    "RDA_NOT_CONNECTED", 
    "RDA_ENV_ERR", 
    "RDA_CONNECT_ERR", 
    "RDA_DISCONNECT_ERR", 
    "RDA_CLOSE_ENV_ERR", 
    "RDA_SQL_ERR", 
    "RDA_CONFIG_FILE_ERR", 
    "RDA_ACCESS_PROHIBITED", 
    "RDA_NAME_NOT_FOUND", 
    "CAT_TICKET_INVALID", 
    "CAT_TICKET_EXPIRED", 
    "CAT_TICKET_USES_EXCEEDED", 
    "CAT_TICKET_USER_EXCLUDED", 
    "CAT_TICKET_HOST_EXCLUDED", 
    "CAT_TICKET_GROUP_EXCLUDED", 
    "CAT_TICKET_WRITE_USES_EXCEEDED", 
    "CAT_TICKET_WRITE_BYTES_EXCEEDED", 
    "FILE_OPEN_ERR", 
    "FILE_READ_ERR", 
    "FILE_WRITE_ERR", 
    "PASSWORD_EXCEEDS_MAX_SIZE", 
    "ENVIRONMENT_VAR_HOME_NOT_DEFINED", 
    "UNABLE_TO_STAT_FILE", 
    "AUTH_FILE_NOT_ENCRYPTED", 
    "AUTH_FILE_DOES_NOT_EXIST", 
    "UNLINK_FAILED", 
    "NO_PASSWORD_ENTERED", 
    "REMOTE_SERVER_AUTHENTICATION_FAILURE", 
    "REMOTE_SERVER_AUTH_NOT_PROVIDED", 
    "REMOTE_SERVER_AUTH_EMPTY", 
    "REMOTE_SERVER_SID_NOT_DEFINED", 
    "UNSUPPORTED_HASH_TYPE_USED", 
    "GSI_NOT_COMPILED_IN", 
    "GSI_NOT_BUILT_INTO_CLIENT", 
    "GSI_NOT_BUILT_INTO_SERVER", 
    "GSI_ERROR_IMPORT_NAME", 
    "GSI_ERROR_INIT_SECURITY_CONTEXT", 
    "GSI_ERROR_SENDING_TOKEN_LENGTH", 
    "GSI_ERROR_READING_TOKEN_LENGTH", 
    "GSI_ERROR_TOKEN_TOO_LARGE", 
    "GSI_ERROR_BAD_TOKEN_RCVED", 
    "GSI_SOCKET_READ_ERROR", 
    "GSI_PARTIAL_TOKEN_READ", 
    "GSI_SOCKET_WRITE_ERROR", 
    "GSI_ERROR_FROM_GSI_LIBRARY", 
    "GSI_ERROR_IMPORTING_NAME", 
    "GSI_ERROR_ACQUIRING_CREDS", 
    "GSI_ACCEPT_SEC_CONTEXT_ERROR", 
    "GSI_ERROR_DISPLAYING_NAME", 
    "GSI_ERROR_RELEASING_NAME", 
    "GSI_DN_DOES_NOT_MATCH_USER", 
    "GSI_QUERY_INTERNAL_ERROR", 
    "GSI_NO_MATCHING_DN_FOUND", 
    "GSI_MULTIPLE_MATCHING_DN_FOUND", 
    "KRB_NOT_COMPILED_IN", 
    "KRB_NOT_BUILT_INTO_CLIENT", 
    "KRB_NOT_BUILT_INTO_SERVER", 
    "KRB_ERROR_IMPORT_NAME", 
    "KRB_ERROR_INIT_SECURITY_CONTEXT", 
    "KRB_ERROR_SENDING_TOKEN_LENGTH", 
    "KRB_ERROR_READING_TOKEN_LENGTH", 
    "KRB_ERROR_TOKEN_TOO_LARGE", 
    "KRB_ERROR_BAD_TOKEN_RCVED", 
    "KRB_SOCKET_READ_ERROR", 
    "KRB_PARTIAL_TOKEN_READ", 
    "KRB_SOCKET_WRITE_ERROR", 
    "KRB_ERROR_FROM_KRB_LIBRARY", 
    "KRB_ERROR_IMPORTING_NAME", 
    "KRB_ERROR_ACQUIRING_CREDS", 
    "KRB_ACCEPT_SEC_CONTEXT_ERROR", 
    "KRB_ERROR_DISPLAYING_NAME", 
    "KRB_ERROR_RELEASING_NAME", 
    "KRB_USER_DN_NOT_FOUND", 
    "KRB_NAME_MATCHES_MULTIPLE_USERS", 
    "KRB_QUERY_INTERNAL_ERROR", 
    "OSAUTH_NOT_BUILT_INTO_CLIENT", 
    "OSAUTH_NOT_BUILT_INTO_SERVER", 
    "PAM_AUTH_NOT_BUILT_INTO_CLIENT", 
    "PAM_AUTH_NOT_BUILT_INTO_SERVER", 
    "PAM_AUTH_PASSWORD_FAILED", 
    "PAM_AUTH_PASSWORD_INVALID_TTL", 
    "OBJPATH_EMPTY_IN_STRUCT_ERR", 
    "RESCNAME_EMPTY_IN_STRUCT_ERR", 
    "DATATYPE_EMPTY_IN_STRUCT_ERR", 
    "DATASIZE_EMPTY_IN_STRUCT_ERR", 
    "CHKSUM_EMPTY_IN_STRUCT_ERR", 
    "VERSION_EMPTY_IN_STRUCT_ERR", 
    "FILEPATH_EMPTY_IN_STRUCT_ERR", 
    "REPLNUM_EMPTY_IN_STRUCT_ERR", 
    "REPLSTATUS_EMPTY_IN_STRUCT_ERR", 
    "DATAOWNER_EMPTY_IN_STRUCT_ERR", 
    "DATAOWNERZONE_EMPTY_IN_STRUCT_ERR", 
    "DATAEXPIRY_EMPTY_IN_STRUCT_ERR", 
    "DATACOMMENTS_EMPTY_IN_STRUCT_ERR", 
    "DATACREATE_EMPTY_IN_STRUCT_ERR", 
    "DATAMODIFY_EMPTY_IN_STRUCT_ERR", 
    "DATAACCESS_EMPTY_IN_STRUCT_ERR", 
    "DATAACCESSINX_EMPTY_IN_STRUCT_ERR", 
    "NO_RULE_FOUND_ERR", 
    "NO_MORE_RULES_ERR", 
    "UNMATCHED_ACTION_ERR", 
    "RULES_FILE_READ_ERROR", 
    "ACTION_ARG_COUNT_MISMATCH", 
    "MAX_NUM_OF_ARGS_IN_ACTION_EXCEEDED", 
    "UNKNOWN_PARAM_IN_RULE_ERR", 
    "DESTRESCNAME_EMPTY_IN_STRUCT_ERR", 
    "BACKUPRESCNAME_EMPTY_IN_STRUCT_ERR", 
    "DATAID_EMPTY_IN_STRUCT_ERR", 
    "COLLID_EMPTY_IN_STRUCT_ERR", 
    "RESCGROUPNAME_EMPTY_IN_STRUCT_ERR", 
    "STATUSSTRING_EMPTY_IN_STRUCT_ERR", 
    "DATAMAPID_EMPTY_IN_STRUCT_ERR", 
    "USERNAMECLIENT_EMPTY_IN_STRUCT_ERR", 
    "RODSZONECLIENT_EMPTY_IN_STRUCT_ERR", 
    "USERTYPECLIENT_EMPTY_IN_STRUCT_ERR", 
    "HOSTCLIENT_EMPTY_IN_STRUCT_ERR", 
    "AUTHSTRCLIENT_EMPTY_IN_STRUCT_ERR", 
    "USERAUTHSCHEMECLIENT_EMPTY_IN_STRUCT_ERR", 
    "USERINFOCLIENT_EMPTY_IN_STRUCT_ERR", 
    "USERCOMMENTCLIENT_EMPTY_IN_STRUCT_ERR", 
    "USERCREATECLIENT_EMPTY_IN_STRUCT_ERR", 
    "USERMODIFYCLIENT_EMPTY_IN_STRUCT_ERR", 
    "USERNAMEPROXY_EMPTY_IN_STRUCT_ERR", 
    "RODSZONEPROXY_EMPTY_IN_STRUCT_ERR", 
    "USERTYPEPROXY_EMPTY_IN_STRUCT_ERR", 
    "HOSTPROXY_EMPTY_IN_STRUCT_ERR", 
    "AUTHSTRPROXY_EMPTY_IN_STRUCT_ERR", 
    "USERAUTHSCHEMEPROXY_EMPTY_IN_STRUCT_ERR", 
    "USERINFOPROXY_EMPTY_IN_STRUCT_ERR", 
    "USERCOMMENTPROXY_EMPTY_IN_STRUCT_ERR", 
    "USERCREATEPROXY_EMPTY_IN_STRUCT_ERR", 
    "USERMODIFYPROXY_EMPTY_IN_STRUCT_ERR", 
    "COLLNAME_EMPTY_IN_STRUCT_ERR", 
    "COLLPARENTNAME_EMPTY_IN_STRUCT_ERR", 
    "COLLOWNERNAME_EMPTY_IN_STRUCT_ERR", 
    "COLLOWNERZONE_EMPTY_IN_STRUCT_ERR", 
    "COLLEXPIRY_EMPTY_IN_STRUCT_ERR", 
    "COLLCOMMENTS_EMPTY_IN_STRUCT_ERR", 
    "COLLCREATE_EMPTY_IN_STRUCT_ERR", 
    "COLLMODIFY_EMPTY_IN_STRUCT_ERR", 
    "COLLACCESS_EMPTY_IN_STRUCT_ERR", 
    "COLLACCESSINX_EMPTY_IN_STRUCT_ERR", 
    "COLLMAPID_EMPTY_IN_STRUCT_ERR", 
    "COLLINHERITANCE_EMPTY_IN_STRUCT_ERR", 
    "RESCZONE_EMPTY_IN_STRUCT_ERR", 
    "RESCLOC_EMPTY_IN_STRUCT_ERR", 
    "RESCTYPE_EMPTY_IN_STRUCT_ERR", 
    "RESCTYPEINX_EMPTY_IN_STRUCT_ERR", 
    "RESCCLASS_EMPTY_IN_STRUCT_ERR", 
    "RESCCLASSINX_EMPTY_IN_STRUCT_ERR", 
    "RESCVAULTPATH_EMPTY_IN_STRUCT_ERR", 
    "NUMOPEN_ORTS_EMPTY_IN_STRUCT_ERR", 
    "PARAOPR_EMPTY_IN_STRUCT_ERR", 
    "RESCID_EMPTY_IN_STRUCT_ERR", 
    "GATEWAYADDR_EMPTY_IN_STRUCT_ERR", 
    "RESCMAX_BJSIZE_EMPTY_IN_STRUCT_ERR", 
    "FREESPACE_EMPTY_IN_STRUCT_ERR", 
    "FREESPACETIME_EMPTY_IN_STRUCT_ERR", 
    "FREESPACETIMESTAMP_EMPTY_IN_STRUCT_ERR", 
    "RESCINFO_EMPTY_IN_STRUCT_ERR", 
    "RESCCOMMENTS_EMPTY_IN_STRUCT_ERR", 
    "RESCCREATE_EMPTY_IN_STRUCT_ERR", 
    "RESCMODIFY_EMPTY_IN_STRUCT_ERR", 
    "INPUT_ARG_NOT_WELL_FORMED_ERR", 
    "INPUT_ARG_OUT_OF_ARGC_RANGE_ERR", 
    "INSUFFICIENT_INPUT_ARG_ERR", 
    "INPUT_ARG_DOES_NOT_MATCH_ERR", 
    "RETRY_WITHOUT_RECOVERY_ERR", 
    "CUT_ACTION_PROCESSED_ERR", 
    "ACTION_FAILED_ERR", 
    "FAIL_ACTION_ENCOUNTERED_ERR", 
    "VARIABLE_NAME_TOO_LONG_ERR", 
    "UNKNOWN_VARIABLE_MAP_ERR", 
    "UNDEFINED_VARIABLE_MAP_ERR", 
    "NULL_VALUE_ERR", 
    "DVARMAP_FILE_READ_ERROR", 
    "NO_RULE_OR_MSI_FUNCTION_FOUND_ERR", 
    "FILE_CREATE_ERROR", 
    "FMAP_FILE_READ_ERROR", 
    "DATE_FORMAT_ERR", 
    "RULE_FAILED_ERR", 
    "NO_MICROSERVICE_FOUND_ERR", 
    "INVALID_REGEXP", 
    "INVALID_OBJECT_NAME", 
    "INVALID_OBJECT_TYPE", 
    "NO_VALUES_FOUND", 
    "NO_COLUMN_NAME_FOUND", 
    "BREAK_ACTION_ENCOUNTERED_ERR", 
    "CUT_ACTION_ON_SUCCESS_PROCESSED_ERR", 
    "MSI_OPERATION_NOT_ALLOWED", 
    "MAX_NUM_OF_ACTION_IN_RULE_EXCEEDED", 
    "MSRVC_FILE_READ_ERROR", 
    "MSRVC_VERSION_MISMATCH", 
    "MICRO_SERVICE_OBJECT_TYPE_UNDEFINED", 
    "MSO_OBJ_GET_FAILED", 
    "REMOTE_IRODS_CONNECT_ERR", 
    "REMOTE_SRB_CONNECT_ERR", 
    "MSO_OBJ_PUT_FAILED", 
    "RE_PARSER_ERROR", 
    "RE_UNPARSED_SUFFIX", 
    "RE_POINTER_ERROR", 
    "RE_RUNTIME_ERROR", 
    "RE_DIVISION_BY_ZERO", 
    "RE_BUFFER_OVERFLOW", 
    "RE_UNSUPPORTED_OP_OR_TYPE", 
    "RE_UNSUPPORTED_SESSION_VAR", 
    "RE_UNABLE_TO_WRITE_LOCAL_VAR", 
    "RE_UNABLE_TO_READ_LOCAL_VAR", 
    "RE_UNABLE_TO_WRITE_SESSION_VAR", 
    "RE_UNABLE_TO_READ_SESSION_VAR", 
    "RE_UNABLE_TO_WRITE_VAR", 
    "RE_UNABLE_TO_READ_VAR", 
    "RE_PATTERN_NOT_MATCHED", 
    "RE_STRING_OVERFLOW", 
    "RE_UNKNOWN_ERROR", 
    "RE_OUT_OF_MEMORY", 
    "RE_SHM_UNLINK_ERROR", 
    "RE_FILE_STAT_ERROR", 
    "RE_UNSUPPORTED_AST_NODE_TYPE", 
    "RE_UNSUPPORTED_SESSION_VAR_TYPE", 
    "RE_TYPE_ERROR", 
    "RE_FUNCTION_REDEFINITION", 
    "RE_DYNAMIC_TYPE_ERROR", 
    "RE_DYNAMIC_COERCION_ERROR", 
    "RE_PACKING_ERROR", 
    "PHP_EXEC_SCRIPT_ERR", 
    "PHP_REQUEST_STARTUP_ERR", 
    "PHP_OPEN_SCRIPT_FILE_ERR", 
    "DBR_NOT_COMPILED_IN", 
    "DBR_ENV_ERR", 
    "DBR_CONNECT_ERR", 
    "DBR_DISCONNECT_ERR", 
    "DBR_CLOSE_ENV_ERR", 
    "DBO_SQL_ERR", 
    "DBR_CONFIG_FILE_ERR", 
    "DBR_MAX_SESSIONS_REACHED", 
    "DBR_NOT_OPEN", 
    "DBR_NAME_NOT_FOUND", 
    "DBO_INVALID_CONTROL_OPTION", 
    "DBR_ALREADY_OPEN", 
    "DBO_DOES_NOT_EXIST", 
    "DBR_ACCESS_PROHIBITED", 
    "DBO_NOT_VALID_DATATYPE", 
    "DBR_WRITABLE_BY_TOO_MANY", 
    "DBO_WRITABLE_BY_TOO_MANY", 
    "DBO_WRITABLE_BY_NON_PRIVILEGED", 
    "NETCDF_OPEN_ERR", 
    "NETCDF_CREATE_ERR", 
    "NETCDF_CLOSE_ERR", 
    "NETCDF_INVALID_PARAM_TYPE", 
    "NETCDF_INQ_ID_ERR", 
    "NETCDF_GET_VARS_ERR", 
    "NETCDF_INVALID_DATA_TYPE", 
    "NETCDF_INQ_VARS_ERR", 
    "NETCDF_VARS_DATA_TOO_BIG", 
    "NETCDF_DIM_MISMATCH_ERR", 
    "NETCDF_INQ_ERR", 
    "NETCDF_INQ_FORMAT_ERR", 
    "NETCDF_INQ_DIM_ERR", 
    "NETCDF_INQ_ATT_ERR", 
    "NETCDF_GET_ATT_ERR", 
    "NETCDF_VAR_COUNT_OUT_OF_RANGE", 
    "NETCDF_UNMATCHED_NAME_ERR", 
    "NETCDF_NO_UNLIMITED_DIM", 
    "NETCDF_PUT_ATT_ERR", 
    "NETCDF_DEF_DIM_ERR", 
    "NETCDF_DEF_VAR_ERR", 
    "NETCDF_PUT_VARS_ERR", 
    "NETCDF_AGG_INFO_FILE_ERR", 
    "NETCDF_AGG_ELE_INX_OUT_OF_RANGE", 
    "NETCDF_AGG_ELE_FILE_NOT_OPENED", 
    "NETCDF_AGG_ELE_FILE_NO_TIME_DIM", 
    "NETCDF_BUILD_WITH_NETCDF_API_NEEDED", 
    "SSL_NOT_BUILT_INTO_CLIENT", 
    "SSL_NOT_BUILT_INTO_SERVER", 
    "SSL_INIT_ERROR", 
    "SSL_HANDSHAKE_ERROR", 
    "SSL_SHUTDOWN_ERROR", 
    "SSL_CERT_ERROR", 
    "OOI_CURL_EASY_INIT_ERR", 
    "OOI_JSON_OBJ_SET_ERR", 
    "OOI_DICT_TYPE_NOT_SUPPORTED", 
    "OOI_JSON_PACK_ERR", 
    "OOI_JSON_DUMP_ERR", 
    "OOI_CURL_EASY_PERFORM_ERR", 
    "OOI_JSON_LOAD_ERR", 
    "OOI_JSON_GET_ERR", 
    "OOI_JSON_NO_ANSWER_ERR", 
    "OOI_JSON_TYPE_ERR", 
    "OOI_JSON_INX_OUT_OF_RANGE", 
    "OOI_REVID_NOT_FOUND", 
    "XML_PARSING_ERR", 
    "OUT_OF_URL_PATH", 
    "URL_PATH_INX_OUT_OF_RANGE", 
    "SYS_NULL_INPUT", 
    "SYS_HANDLER_DONE_WITH_ERROR", 
    "SYS_HANDLER_DONE_NO_ERROR", 
    "SYS_NO_HANDLER_REPLY_MSG", 
};
int irodsErrorCount= 626;
/* END generated code */

static int verbosityLevel=LOG_ERROR;
static int sqlVerbosityLevel=0;
pid_t myPid=0;

#ifdef windows_platform
static void rodsNtElog(char *msg);
#endif

/*
 Log or display a message.  The level argument indicates how severe
 the message is, and depending on the verbosityLevel may or may not be
 recorded.  This is used by both client and server code.
 */
void
rodsLog(int level, char *formatStr, ...) {
   char bigString[BIG_STRING_LEN];
   char *prefix;
   time_t timeValue;
   int i;
   FILE *errOrOut;
   va_list ap;

#ifdef IRODS_SYSLOG
   char *myZone = getenv("spProxyRodsZone");
#endif
   int okToLog = 0;

   char extraInfo[100];
#ifdef windows_platform
   char nt_log_msg[2048];
#endif

   if (level <= verbosityLevel)
   {
      okToLog = 1;
   }
   
   if (level == LOG_SQL)
   {
      okToLog = 1;
   }

   if (!okToLog) return;

   va_start(ap, formatStr);
   i = vsnprintf(bigString, BIG_STRING_LEN-1, formatStr, ap);
   va_end(ap);
   
   extraInfo[0]='\0';
#ifndef windows_platform
   errOrOut = stdout;
#endif
   if (ProcessType == SERVER_PT || ProcessType == AGENT_PT ||
     ProcessType == RE_SERVER_PT) {
      char timeBuf[100];
      time(&timeValue);
      rstrcpy(timeBuf, ctime(&timeValue), 90);
      timeBuf[19]='\0';
      myPid = getpid();
      snprintf(extraInfo, 100-1, "%s pid:%d ", timeBuf+4, myPid);
   }
   else {
#ifndef windows_platform
      if (level <= LOG_ERROR || level == LOG_SQL) errOrOut=stderr;
#endif
   }

   prefix="";
   if (level == LOG_SQL) prefix="LOG_SQL";
   if (level == LOG_SYS_FATAL) prefix="SYSTEM FATAL";
   if (level == LOG_SYS_WARNING) prefix="SYSTEM WARNING";
   if (level == LOG_ERROR) prefix="ERROR";
   if (level == LOG_NOTICE) prefix="NOTICE";
#ifdef IRODS_SYSLOG
   if (level == LOG_DEBUG) prefix="DEBUG";
   if (level == LOG_DEBUG1) prefix="DEBUG1";
   if (level == LOG_DEBUG2) prefix="DEBUG2";
   if (level == LOG_DEBUG3) prefix="DEBUG3";
   if (ProcessType == SERVER_PT || ProcessType == AGENT_PT ||
       ProcessType == RE_SERVER_PT) 
#else
   if (level == LOG_DEBUG) prefix="DEBUG";
   if (level == LOG_DEBUG1) prefix="DEBUG1";
   if (level == LOG_DEBUG2) prefix="DEBUG2";
   if (level == LOG_DEBUG3) prefix="DEBUG3";
   if (bigString[strlen(bigString)-1]=='\n')
#endif
   {
#ifdef IRODS_SYSLOG
#ifdef SYSLOG_FACILITY_CODE
     syslog(SYSLOG_FACILITY_CODE|LOG_NOTICE,"%s - %s: %s", myZone, prefix, bigString);
#else
     syslog(LOG_DAEMON|LOG_NOTICE,"%s - %s: %s", myZone, prefix, bigString);
#endif
#else
#ifndef windows_platform
      fprintf(errOrOut, "%s%s: %s", extraInfo, prefix, bigString);
#else
	  sprintf(nt_log_msg, "%s%s: %s", extraInfo, prefix, bigString);
	  rodsNtElog(nt_log_msg);
#endif
#endif
   }
   else 
   {
#ifndef windows_platform
      fprintf(errOrOut, "%s%s: %s\n", extraInfo, prefix, bigString);
#else
	   sprintf(nt_log_msg, "%s%s: %s\n", extraInfo, prefix, bigString);
	   rodsNtElog(nt_log_msg);
#endif
   }
#ifndef windows_platform
   fflush (errOrOut);
#endif
}

/* same as rodsLog plus putting the msg in myError too. Need to merge with
 * rodsLog
 */

void
rodsLogAndErrorMsg (int level, rError_t *myError, int status,
char *formatStr, ...) {
   char bigString[BIG_STRING_LEN];
   char *prefix;
   time_t timeValue;
   int i;
   FILE *errOrOut;
   va_list ap;
   char errMsg[ERR_MSG_LEN];

   char extraInfo[100];
#ifdef windows_platform
   char nt_log_msg[2048];
#endif

   if (level > verbosityLevel) return;


   va_start(ap, formatStr);
   i = vsnprintf(bigString, BIG_STRING_LEN-1, formatStr, ap);
   va_end(ap);
   
   extraInfo[0]='\0';
   errOrOut = stdout;
   if (ProcessType == SERVER_PT || ProcessType == AGENT_PT ||
     ProcessType == RE_SERVER_PT) {
      char timeBuf[100];
      time(&timeValue);
      rstrcpy(timeBuf, ctime(&timeValue), 90);
      timeBuf[19]='\0';
      myPid = getpid();
      snprintf(extraInfo, 100-1, "%s pid:%d ", timeBuf+4, myPid);
   }
   else {
      if (level <= LOG_ERROR || level == LOG_SQL) errOrOut=stderr;
   }

   prefix="";
   if (level == LOG_SQL) prefix="LOG_SQL";
   if (level == LOG_SYS_FATAL) prefix="SYSTEM FATAL";
   if (level == LOG_SYS_WARNING) prefix="SYSTEM WARNING";
   if (level == LOG_ERROR) prefix="ERROR";
   if (level == LOG_NOTICE) prefix="NOTICE";
   if (level <= LOG_DEBUG) prefix="DEBUG";
   if (bigString[strlen(bigString)-1]=='\n') 
   {
#ifndef windows_platform
      fprintf(errOrOut, "%s%s: %s", extraInfo, prefix, bigString);
      if (myError != NULL) {
         snprintf (errMsg, ERR_MSG_LEN,
           "%s: %s", prefix, bigString);
         addRErrorMsg (myError, status, errMsg);
      } 
#else
	   sprintf(nt_log_msg, "%s%s: %s", extraInfo, prefix, bigString);
	   rodsNtElog(nt_log_msg);
#endif
   }
   else 
   {
#ifndef windows_platform
      fprintf(errOrOut, "%s%s: %s\n", extraInfo, prefix, bigString);
      if (myError != NULL) {
         snprintf (errMsg, ERR_MSG_LEN,
           "%s: %s\n", prefix, bigString);
         addRErrorMsg (myError, status, errMsg);
      }
#else
	   sprintf(nt_log_msg, "%s%s: %s\n", extraInfo, prefix, bigString);
	   rodsNtElog(nt_log_msg);
#endif
   }

#ifndef windows_platform
   fflush (errOrOut);
#endif
}

/*
 Change the verbosityLevel of reporting.
 The input value is the new minimum level of message to report.
 */
void 
rodsLogLevel(int level) {
   verbosityLevel = level;
}

int
getRodsLogLevel ()
{
    return (verbosityLevel);
}

/*
 Request sql logging.
 */
void 
rodsLogSqlReq(int onOrOff) {
   sqlVerbosityLevel=onOrOff;
}

void
rodsLogSql(char *sql) {
   myPid = getpid();
   if (sqlVerbosityLevel) rodsLog(LOG_SQL, "pid: %d sql: %s", 
				  myPid, sql);
}
void
rodsLogSqlResult(char *stat) {
   myPid = getpid();
   if (sqlVerbosityLevel) rodsLog(LOG_SQL, "pid: %d result: %s", 
				  myPid, stat);
}

/* 
Convert an iRODS error code to the corresponding name.
 */
char *
rodsErrorName(int errorValue, char **subName)
{
   int i;
   int testVal;
   int subCode;

   testVal = errorValue/1000;

   *subName="";
   subCode = errorValue - (testVal*1000);
   if (subCode && *subName && errorValue<0) {
      *subName = strerror(-subCode);
   }

   for (i=0;i<irodsErrorCount;i++) {
      if (testVal==irodsErrors[i]/1000) {
	 return(irodsErrorNames[i]);
      }
   }
   return("Unknown iRODS error");
}

/*
 Convert an error code to a string and log it.
 This was originally called rodsLogError, but was renamed when we
 created the new rodsLogError below.  This is no longer used (
 rodsLogError can be called with the same arguments).
 */
void
rodsLogErrorOld(int level, int rodsErrorCode, char *textStr) {
   char *errName;
   char *errSubName;

   if (level < verbosityLevel) return;

   errName = rodsErrorName(rodsErrorCode, &errSubName);
   if (textStr && strlen(textStr)>0) {
      rodsLog(level, "%s Error: %d: %s, %s", textStr, rodsErrorCode,
	      errName, errSubName);
   }
   else {
      rodsLog(level, "Error: %d: %s, %s", rodsErrorCode, 
	      errName, errSubName);
   }
}

/* Like rodsLogError but with full rodsLog functionality too.
   Converts the errorcode to a string, and possibly a subcode string,
   and includes that at the end of a regular log message (with
   variable arguments).
 */
void
rodsLogError(int level, int rodsErrorCode, char *formatStr, ...) {
   char bigString[BIG_STRING_LEN];
   int i;
   char *errName;
   char *errSubName;
   va_list ap;

   if (level > verbosityLevel) return;

   
   va_start(ap, formatStr);
   i = vsnprintf(bigString, BIG_STRING_LEN-1, formatStr, ap);
   va_end(ap);
   
   errName = rodsErrorName(rodsErrorCode, &errSubName);
   if (strlen(errSubName)>0) {
      rodsLog(level, "%s status = %d %s, %s", bigString, rodsErrorCode,
	      errName, errSubName);
   }
   else {
      rodsLog(level, "%s status = %d %s", bigString, rodsErrorCode,
	      errName);
   }
}

#ifdef windows_platform
static void rodsNtElog(char *msg)
{
	char log_fname[1024];
	int fd;
	int t;

	if(ProcessType == CLIENT_PT)
	{
		fprintf(stderr,"%s", msg);
	    return;
	}

	t = strlen(msg);
	if(msg[t-1] == '\n')
	{
		msg[t-1] = '\0';
		t = t -1;
	}

	if(iRODSNtServerRunningConsoleMode())
	{
		t = strlen(msg);
		if(msg[t-1] == '\n')
			fprintf(stderr,"%s",msg);
		else
			fprintf(stderr,"%s\n",msg);
		return;
	}

	t = strlen(msg);
	if(msg[t-1] != '\n')
	{
		msg[t] = '\n';
		msg[t+1] = '\0';
		t = t +1;
	}

	iRODSNtGetLogFilenameWithPath(log_fname);
	fd = iRODSNt_open(log_fname, O_APPEND|O_WRONLY,1);
	_write(fd,msg,t);
	_close(fd);
}
#endif

/*
 * This function will generate an ISO 8601 formatted 
 * date/time stamp for use in log messages. The format
 * will be 'YYYYMMDDThhmmss.uuuuuuZ' where:
 *
 * YYYY - is the year 
 *   MM - is the month (01-12)
 *   DD - is the day   (01-31)
 *   hh - is the hour (00-24)
 *   mm - is the minute (00-59)
 *   ss - is the second (00-59)
 *   u+ - are the number of microseconds.
 *
 * The date/time stamp is in UTC time.
 */
void 
generateLogTimestamp(char *ts, int tsLen)
{
    struct timeval tv;
    struct tm utc;
    char timestamp[TIME_LEN];

    if (ts == NULL) {
        return;
    }

    gettimeofday(&tv, NULL);
    gmtime_r(&tv.tv_sec, &utc);
    strftime(timestamp, TIME_LEN, "%Y%m%dT%H%M%S", &utc);
    
    /* 8 characters of '.uuuuuuZ' + nul */
    if (tsLen < (int)strlen(timestamp) + 9) {
        return;
    }

    snprintf(ts, strlen(timestamp) + 9, "%s.%06dZ", timestamp, (int)tv.tv_usec);
}

